package com.chcit.share.generator.service.impl;

import java.util.List;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.chcit.share.generator.model.TemplateFileModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.chcit.share.admin.core.page.MybatisPageHelper;
import com.chcit.share.admin.core.page.PageRequest;
import com.chcit.share.admin.core.page.PageResult;
import com.chcit.share.generator.dao.TemplateFileMapper;
import com.chcit.share.generator.service.TemplateFileService;

/**
 * ---------------------------
 * 模板文件内容 (TemplateFileServiceImpl)         
 * ---------------------------
 * 作者：  liuyang
 * 时间：  2019-05-05 14:54:15
 * 说明：  我是由代码生成器生生成的
 * ---------------------------
 */
@Service
public class TemplateFileServiceImpl implements TemplateFileService {

	@Autowired
	private TemplateFileMapper genTemplateFileMapper;

	@Override
	public int save(TemplateFileModel record) {
		if(record.getId() == null || record.getId() == 0) {
			return genTemplateFileMapper.add(record);
		}
		return genTemplateFileMapper.update(record);
	}

	@Override
	public int delete(TemplateFileModel record) {
		return genTemplateFileMapper.delete(record.getId());
	}

	@Override
	public int delete(List<TemplateFileModel> records) {
		for(TemplateFileModel record:records) {
			delete(record);
		}
		return 1;
	}

	@Override
	public TemplateFileModel findById(Long id) {
		return genTemplateFileMapper.findById(id);
	}

	@Override
	public PageResult findPage(PageRequest pageRequest) {
		return MybatisPageHelper.findPage(pageRequest, genTemplateFileMapper);
	}

	@Override
	public TemplateFileModel selectOne(TemplateFileModel entity) {
		Wrapper<TemplateFileModel> queryWrapper = new QueryWrapper<>(entity);
		return genTemplateFileMapper.selectOne(queryWrapper);
	}
}
